from datetime import datetime
from utils.upload_image import choose_random_image
from utils.screenshot.step_screenshot import step_screenshot


class DigitalHumanPage:
    def __init__(self, page):
        self.page = page

    def go_to_avatar_pic_page(self,):
        self.page.goto("https://hi-dev.lingverse.co/avatar")
        self.page.click("text=快速创建数字人")

        self.page.click("text=图片生成数字人")
        content = "ui自动化图片数字人" + datetime.now().strftime("%Y%m%d%H%M%S")
        self.page.fill("input[placeholder='请输入数字人名称']", content)

    def upload_avatar(self, image_path: str):
        self.page.set_input_files("input[type='file']", str(image_path))

    def select_video_model_3(self):
        self.page.click("button:has-text('图生视频 3.0')")  # 图生视频3.0

    def select_video_model_2(self):
        self.page.click("button:has-text('图生视频 2.1')")

    def submit_create(self):
        self.page.click("button:has-text('提 交')")
        self.page.wait_for_selector("text=创建成功", timeout=15000)


